package com.zhht.checkcop.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhbc.framework.dao.IBaseDao;
import com.zhbc.framework.service.ABaseServiceImpl;
import com.zhht.checkcop.check.vo.CatalogVO;
import com.zhht.checkcop.check.vo.ClassifyDirectionVO;
import com.zhht.checkcop.dao.CatalogDao;
import com.zhht.checkcop.service.CatalogService;

@Transactional
@Service("catalogService")
public class CatalogServiceImpl extends ABaseServiceImpl<CatalogVO> implements CatalogService{
	
	@Autowired
	private CatalogDao catalogDao;
	
	@Override
	protected IBaseDao<CatalogVO> getBaseDao() {
		// TODO Auto-generated method stub
		return this.catalogDao;
	}

	@Override
	public PageInfo<CatalogVO> getListByNovelId(String novelId,
			String tableName, String order,int pageNum,int pageSize) {
		Map<String,Object> param=new HashMap<String,Object>();
		param.put("tableName", tableName);
		param.put("novelId", Integer.parseInt(novelId));
		param.put("order", order);
		
		PageHelper.startPage(pageNum, pageSize);
		List<CatalogVO> listByNovelId = catalogDao.queryListByNovelId(param);
		return new PageInfo<CatalogVO>(listByNovelId);
	}

	@Override
	public CatalogVO getCatalogByCatalogId(String novelId, String tableName) {
		// TODO Auto-generated method stub
		return null;
	}
	
	public Map<String,ClassifyDirectionVO> getTableName(){
		Map<String,ClassifyDirectionVO> map=null;
		List<ClassifyDirectionVO> listTableName = catalogDao.getTableName();
		if(listTableName!=null&&listTableName.size()>0){
			map=new HashMap<String, ClassifyDirectionVO>();
			for(ClassifyDirectionVO cdVO:listTableName){
				map.put(cdVO.getClassify_id(), cdVO);
			}
		}
		return map;
	}

}
